<?php
        //调用配置文件config.php
        require_once 'config.php';
        //连接数据库
        $conn = mysql_connect($host, $dbusername,$dbpassword);
        if(!$conn){
                die("连接失败".mysql_error());
        }
        //设置访问数据库的编码
        mysql_query("set names utf8",$conn) or die(mysql_errno());
        //选择数据库
        mysql_select_db($dbname,$conn) or die(mysql_errno());

	//修改用户名和密码
	$name = $_POST['username'];
	echo $name;
	$password = $_POST['password'];
	$sql = "update admin set name='$name',password=md5('$password') where id=1";
	$res = mysql_query($sql, $conn) ;
		
	//修改导航栏
	$catalog = $_POST['catalog'];
	for($i=0;$i<count($catalog);$i++){
		$sql = "update catalogs set catalog='$catalog[$i]' where cid=$i+1";
		$res = mysql_query($sql, $conn)or die(mysql_error());
		echo $res;
	}
	
	//执行完毕，界面跳转回去，并发送成功的信号
	header('Location: configManage.php?flag=success');	
?>
